package com.zillion.web.controller.health;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.zillion.common.annotation.Log;
import com.zillion.common.core.controller.BaseController;
import com.zillion.common.core.domain.AjaxResult;
import com.zillion.common.enums.BusinessType;
import com.zillion.health.domain.HealthConfig;
import com.zillion.health.service.IHealthConfigService;
import com.zillion.common.utils.poi.ExcelUtil;
import com.zillion.common.core.page.TableDataInfo;

/**
 * 从业人员配置Controller
 * 
 * @author zillion
 * @date 2025-06-12
 */
@RestController
@RequestMapping("/health/config")
public class HealthConfigController extends BaseController
{
    @Autowired
    private IHealthConfigService healthConfigService;

    /**
     * 查询从业人员配置列表
     */
    @PreAuthorize("@ss.hasPermi('health:config:list')")
    @GetMapping("/list")
    public TableDataInfo list(HealthConfig healthConfig)
    {
        startPage();
        List<HealthConfig> list = healthConfigService.selectHealthConfigList(healthConfig);
        return getDataTable(list);
    }

    /**
     * 导出从业人员配置列表
     */
    @PreAuthorize("@ss.hasPermi('health:config:export')")
    @Log(title = "从业人员配置", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, HealthConfig healthConfig)
    {
        List<HealthConfig> list = healthConfigService.selectHealthConfigList(healthConfig);
        ExcelUtil<HealthConfig> util = new ExcelUtil<HealthConfig>(HealthConfig.class);
        util.exportExcel(response, list, "从业人员配置数据");
    }

    /**
     * 获取从业人员配置详细信息
     */
    @PreAuthorize("@ss.hasPermi('health:config:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(healthConfigService.selectHealthConfigById(id));
    }

    /**
     * 新增从业人员配置
     */
    @PreAuthorize("@ss.hasPermi('health:config:add')")
    @Log(title = "从业人员配置", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody HealthConfig healthConfig)
    {
        return toAjax(healthConfigService.insertHealthConfig(healthConfig));
    }

    /**
     * 修改从业人员配置
     */
    @PreAuthorize("@ss.hasPermi('health:config:edit')")
    @Log(title = "从业人员配置", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody HealthConfig healthConfig)
    {
        return toAjax(healthConfigService.updateHealthConfig(healthConfig));
    }

    /**
     * 删除从业人员配置
     */
    @PreAuthorize("@ss.hasPermi('health:config:remove')")
    @Log(title = "从业人员配置", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
//        return healthConfigService.deleteHealthConfigByIds(ids);
        healthConfigService.deleteHealthConfigByIds(ids);
        return success();
    }
}
